import httpClient from './AChttpClient'

const uploadUrl = '/log-frontend/frontend/send'
function upload(serverUrl, arr = []) {
    const ids = arr.map(r => r.uId)
    httpClient.ajax('POST', serverUrl + uploadUrl, arr).then(function (res) {
        if (res.code - 0 === 0) {
            postMessage({ cmd: 'UPLOAD_SUCCESS', ids })
        }
    }).catch((err) => {
        console.log(err)
    })
}

onmessage = function (event) {
    switch (event.data.cmd) {
        case 'UPLOADLOGLIST':
            const url = event.data.url
            const arr = event.data.row
            upload(url, arr)
            break;
        default:
            break;
    }
};
